import type { PaginationProps } from "@pureadmin/table";

export const baseUrlApi = (url: string) =>
  process.env.NODE_ENV === "development"
    ? `/api${url}`
    : `http://127.0.0.1:3000${url}`;

export const systemUrlApi = (url: string) =>
  process.env.NODE_ENV === "development"
    ? `/api/system${url}`
    : `http://127.0.0.1:3000/system${url}`;

export const jobUrlApi = (url: string) =>
  process.env.NODE_ENV === "development"
    ? `/api/job${url}`
    : `http://127.0.0.1:3000/job${url}`;

export const toBackendPageObj = (pagination: PaginationProps) => {
  return {
    current: pagination.currentPage,
    size: pagination.pageSize
  };
};

export const toFrontendPageObj = (data: any, pagination: PaginationProps) => {
  pagination.total = Number(data.total);
  pagination.pageSize = Number(data.size);
  pagination.currentPage = Number(data.current);
};
